package org.example.common;

import com.alibaba.druid.support.json.JSONParser;
import com.alibaba.druid.support.json.JSONUtils;

import java.util.Base64;
import java.util.HashMap;
import java.util.Map;

public class JsonToBaseUtils {

    public static String base(String json){
        System.out.println(json);
       String msg = Base64.getEncoder().encodeToString(json.getBytes());
       System.out.println(msg);
       return msg;
    }

    public static String base(Map<String,Object> map){
        String json = JSONUtils.toJSONString(map);
        return base(json);
    }

    public static void main(String... args){
        Map<String,Object> map = new HashMap<>();
        map.put("name","oauth");
        map.put("exp",158051157);
        map.put("userId","1");
        base(map);
    }
}
